﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace cmdb.keede.entity.Migrations
{
    public partial class add_createorname_ingroup : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_GROUP_REFERENCE_USER",
                table: "Group");

            migrationBuilder.DropIndex(
                name: "IX_Group_Creator",
                table: "Group");

            migrationBuilder.RenameColumn(
                name: "Creator",
                table: "Group",
                newName: "CreatorName");

            migrationBuilder.AddColumn<string>(
                name: "CreatorId",
                table: "Group",
                unicode: false,
                maxLength: 50,
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_Group_CreatorId",
                table: "Group",
                column: "CreatorId");

            migrationBuilder.AddForeignKey(
                name: "FK_GROUP_REFERENCE_USER",
                table: "Group",
                column: "CreatorId",
                principalTable: "User",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_GROUP_REFERENCE_USER",
                table: "Group");

            migrationBuilder.DropIndex(
                name: "IX_Group_CreatorId",
                table: "Group");

            migrationBuilder.DropColumn(
                name: "CreatorId",
                table: "Group");

            migrationBuilder.RenameColumn(
                name: "CreatorName",
                table: "Group",
                newName: "Creator");

            migrationBuilder.CreateIndex(
                name: "IX_Group_Creator",
                table: "Group",
                column: "Creator");

            migrationBuilder.AddForeignKey(
                name: "FK_GROUP_REFERENCE_USER",
                table: "Group",
                column: "Creator",
                principalTable: "User",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
